//
//  DLBaseSearchTextField.m
//  DGGBaseSDK
//
//  Created by 高安宏 on 2018/9/5.
//  Copyright © 2018年 dgg. All rights reserved.
//

#import "DLBaseSearchTextField.h"

@implementation DLBaseSearchTextField

- (void)setLeftImage:(UIImage *)leftImage
{
    _leftImage = leftImage;
    UIImageView *leftView = [[UIImageView alloc] initWithImage:leftImage];
    self.leftView = leftView;
    self.leftViewMode = UITextFieldViewModeAlways;
}

//UITextField leftView与输入框的距离
- (CGRect)leftViewRectForBounds:(CGRect)bounds
{
    CGRect iconRect = [super leftViewRectForBounds:bounds];
    iconRect.origin.x += self.leftOffset;
    return iconRect;
}

//UITextField 文字与输入框的距离
- (CGRect)textRectForBounds:(CGRect)bounds
{
    return CGRectInset(bounds, CGRectGetMaxX(self.leftView.frame)+self.textLeftOffset, 0);
}

//控制文本的位置
- (CGRect)editingRectForBounds:(CGRect)bounds
{
    return CGRectInset(bounds, CGRectGetMaxX(self.leftView.frame)+self.textLeftOffset, 0);
}


@end
